/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.AssociationClasses;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.Type;
import edu.pku.sei.modeler.model.uml.Kernel.Property;
import edu.pku.sei.modeler.model.uml.Kernel.Property;
import edu.pku.sei.modeler.model.uml.Kernel.UMLElement;

import edu.pku.sei.modeler.model.uml.Kernel.UMLClass;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class AssociationClass extends UMLClass implements IAssociationClass {
	// attributes
	
	
	
	protected boolean isDerived;
	
	
	// references
	
	
	
	protected MetaTypedList endType;
	
	protected MetaTypedList owningAssociation;
	
	protected MetaTypedList navigableOwnedEnd;
	
	protected MetaTypedList relatedElement;
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "ASSOCIATIONCLASS_ISDERIVED",
			catalog = "Model",
			name = ModelPackage.ASSOCIATION_ISDERIVED,
			setter = "setisDerived"
			)
	
	public boolean getIsDerived() {
		return isDerived;
	}
	public void setIsDerived(boolean newIsDerived) {
		boolean oldisDerived = isDerived;
		isDerived = newIsDerived;
		firePropertyChange(ModelPackage.ASSOCIATION_ISDERIVED, oldisDerived, newIsDerived);
	}
	
	// getters for references
	
	public MetaTypedList getEndType() {
		if(endType == null) {
			endType = new MetaTypedList(Type.class, this, ModelPackage.ASSOCIATION_ENDTYPE);
		}
		return endType;
	}
	
	public MetaTypedList getOwningAssociation() {
		if(owningAssociation == null) {
			owningAssociation = new MetaTypedList(Property.class, this, ModelPackage.ASSOCIATION_OWNINGASSOCIATION);
		}
		return owningAssociation;
	}
	
	public MetaTypedList getNavigableOwnedEnd() {
		if(navigableOwnedEnd == null) {
			navigableOwnedEnd = new MetaTypedList(Property.class, this, ModelPackage.ASSOCIATION_NAVIGABLEOWNEDEND);
		}
		return navigableOwnedEnd;
	}
	
	public MetaTypedList getRelatedElement() {
		if(relatedElement == null) {
			relatedElement = new MetaTypedList(UMLElement.class, this, ModelPackage.RELATIONSHIP_RELATEDELEMENT);
		}
		return relatedElement;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.ASSOCIATION_ISDERIVED, isDerived);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ASSOCIATION_ENDTYPE, endType);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ASSOCIATION_OWNINGASSOCIATION, owningAssociation);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ASSOCIATION_NAVIGABLEOWNEDEND, navigableOwnedEnd);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.RELATIONSHIP_RELATEDELEMENT, relatedElement);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isDerived = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.ASSOCIATION_ISDERIVED);
		
		// references
		
		this.getEndType().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ASSOCIATION_ENDTYPE, this));
		
		this.getOwningAssociation().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ASSOCIATION_OWNINGASSOCIATION));
		
		this.getNavigableOwnedEnd().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ASSOCIATION_NAVIGABLEOWNEDEND, this));
		
		this.getRelatedElement().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.RELATIONSHIP_RELATEDELEMENT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.ASSOCIATION_ENDTYPE.equals(featureID)) {
			getEndType().add(value);
		}
		
		else if(ModelPackage.ASSOCIATION_NAVIGABLEOWNEDEND.equals(featureID)) {
			getNavigableOwnedEnd().add(value);
		}
		
		else if(ModelPackage.RELATIONSHIP_RELATEDELEMENT.equals(featureID)) {
			getRelatedElement().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 